package com.huawei.appgallery.assistantdock.buoydock.card.card;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView.a;
import com.huawei.appgallery.assistantdock.base.cardkit.card.BuoyHorizonBaseCard;
import com.huawei.appgallery.assistantdock.buoydock.card.bean.BuoyAppDataItem;
import com.huawei.appgallery.assistantdock.buoydock.card.bean.BuoyHorizonHomeCardBeanBuoy;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.exposure.bean.ExposureDetail;
import java.util.ArrayList;
import java.util.List;
import o.beo$b;
import o.beo$e;
import o.beo$j;
import o.Logger;
import o.SomeTimerTask;
import o.evt;

public class BuoyHorizonHomeCardBuoy extends BuoyHorizonBaseCard {
    private b ʼ;
    private long ॱॱ;

    class b extends SomeTimerTask {
        final /* synthetic */ BuoyHorizonHomeCardBuoy ˋ;

        private b(BuoyHorizonHomeCardBuoy buoyHorizonHomeCardBuoy) {
            this.ˋ = buoyHorizonHomeCardBuoy;
        }

        public int[] getVisibleImtePos() {
            int[] iArr = new int[]{-1, -1};
            if (this.ˋ.ˏ != null) {
                try {
                    iArr[0] = this.ˋ.ˏ.ॱˊ();
                    iArr[1] = this.ˋ.ˏ.ʻॱ();
                } catch (NullPointerException e) {
                    Logger.ˋ("BuoyHorizonHomeCardBuoy", "findFirstVisibleItemPosition error:" + e.toString());
                }
            }
            return iArr;
        }

        public View ˏ(int i) {
            View view = null;
            if (this.ˋ.ˏ != null) {
                try {
                    view = this.ˋ.ˏ.ˋ(i);
                } catch (NullPointerException e) {
                    Logger.ˋ("BuoyHorizonHomeCardBuoy", "getViewByPosition error:" + e.toString());
                }
            }
            return view;
        }

        public List<ExposureDetail> ˏ(int i, int i2) {
            Object obj = evt.ˊ(this.ˋ.ˋ) >= 50 ? 1 : null;
            ArrayList arrayList = new ArrayList();
            if (obj == null) {
                return arrayList;
            }
            ArrayList ˋ = this.ˋ.ˊ(i, i2);
            ExposureDetail exposureDetail = new ExposureDetail();
            exposureDetail.ˎ(ˋ);
            String str = null;
            if (this.ˋ.ˊᐝ != null) {
                str = this.ˋ.ˊᐝ.ॱˉ();
            }
            exposureDetail.ॱ(str);
            exposureDetail.ˏ(System.currentTimeMillis());
            arrayList.add(exposureDetail);
            return arrayList;
        }

        public long ˊ() {
            return this.ˋ.ॱॱ;
        }

        public int ˋ() {
            return 4;
        }
    }

    class c extends com.huawei.appgallery.assistantdock.base.cardkit.card.BuoyHorizonBaseCard.c {
        final /* synthetic */ BuoyHorizonHomeCardBuoy ˊ;

        class b extends d {
            private BuoyAppItemCardBuoy ॱˋ = null;
            final /* synthetic */ c ᐝॱ;

            public b(c cVar, View view) {
                this.ᐝॱ = cVar;
                super(cVar, view);
                this.ॱˋ = new BuoyAppItemCardBuoy(view.getContext());
                this.ॱˋ.ˏ(view);
                this.ॱˋ.ˉ().setClickable(true);
                this.ʻॱ = view;
                this.ॱˋ.ॱ(cVar.ˊ.ˏ());
            }
        }

        private c(BuoyHorizonHomeCardBuoy buoyHorizonHomeCardBuoy) {
            this.ˊ = buoyHorizonHomeCardBuoy;
            super(buoyHorizonHomeCardBuoy);
        }

        public d ˏ(ViewGroup viewGroup, int i) {
            return new b(this, LayoutInflater.from(viewGroup.getContext()).inflate(beo$j.ˊ, viewGroup, false));
        }

        public void ˊ(d dVar, int i) {
            BuoyHorizonHomeCardBeanBuoy buoyHorizonHomeCardBeanBuoy = (BuoyHorizonHomeCardBeanBuoy) this.ˊ.ˊᐝ;
            if (dVar instanceof b) {
                CardBean cardBean = (CardBean) buoyHorizonHomeCardBeanBuoy.ˊ().get(i);
                cardBean.ˋˋ(buoyHorizonHomeCardBeanBuoy.ॱˉ());
                ((b) dVar).ॱˋ.ˏ(cardBean);
            }
        }

        public int ˏ() {
            CardBean ˌ = this.ˊ.ˌ();
            if (ˌ instanceof BuoyHorizonHomeCardBeanBuoy) {
                BuoyHorizonHomeCardBeanBuoy buoyHorizonHomeCardBeanBuoy = (BuoyHorizonHomeCardBeanBuoy) ˌ;
                if (buoyHorizonHomeCardBeanBuoy.ˊ() != null) {
                    return buoyHorizonHomeCardBeanBuoy.ˊ().size();
                }
            }
            return 0;
        }
    }

    public BuoyHorizonHomeCardBuoy(Context context) {
        super(context);
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        TextView textView = (TextView) this.ˊˋ.findViewById(beo$e.ॱ);
        if (textView != null) {
            textView.setTextColor(this.ʼॱ.getResources().getColor(beo$b.ॱ));
        }
    }

    public void ॱ() {
        this.ॱॱ = System.currentTimeMillis();
        this.ʼ = new b();
        this.ʼ.ˏ();
    }

    public a ˊ() {
        return new c();
    }

    public ArrayList<String> ᐝ() {
        if (this.ʼ == null) {
            this.ʼ = new b();
        }
        int[] ॱ = this.ʼ.getVisibleImtePos();
        if (ॱ[0] < 0 || ॱ[1] < 0) {
            return null;
        }
        int i = ॱ[0];
        int i2 = ॱ[1];
        if (i == i2 && evt.ˊ(this.ʼ.ˏ(i)) < 50) {
            return null;
        }
        if (evt.ˊ(this.ʼ.ˏ(i)) < 50) {
            i++;
        }
        if (evt.ˊ(this.ʼ.ˏ(i2)) < 50) {
            i2--;
        }
        return ˊ(i, i2);
    }

    private ArrayList<String> ˊ(int i, int i2) {
        CardBean ˌ = ˌ();
        if (!(ˌ instanceof BuoyHorizonHomeCardBeanBuoy)) {
            return null;
        }
        BuoyHorizonHomeCardBeanBuoy buoyHorizonHomeCardBeanBuoy = (BuoyHorizonHomeCardBeanBuoy) ˌ;
        if (buoyHorizonHomeCardBeanBuoy.ˊ() == null) {
            return null;
        }
        List arrayList = new ArrayList();
        arrayList.addAll(buoyHorizonHomeCardBeanBuoy.ˊ());
        int size = arrayList.size() - 1;
        ArrayList<String> arrayList2 = new ArrayList();
        while (i <= i2 && i <= size) {
            BuoyAppDataItem buoyAppDataItem = (BuoyAppDataItem) arrayList.get(i);
            if (buoyAppDataItem != null) {
                String str = buoyAppDataItem.ॱॱ() + "#$#" + buoyAppDataItem.u_();
                Logger.e("BuoyHorizonHomeCardBuoy", "getExposureDetail:" + str);
                arrayList2.add(str);
            }
            i++;
        }
        return arrayList2;
    }
}
